home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / hsrc_117.zip / TWINDOW.H < prev    next >
Text File  |  1990-11-09  |  7KB  |  227 lines

  1. /* TWindow.H  File */
  2.  
  3. /* Window colors */
  4. #define RED            4
  5. #define GREEN        2
  6. #define BLUE        1
  7. #define WHITE        (RED+GREEN+BLUE)
  8. #define YELLOW        (RED+GREEN)
  9. #define AQUA        (GREEN+BLUE)
  10. #define MAGENTA     (RED+BLUE)
  11. #define BLACK         0
  12. #define BRIGHT        8
  13. #define DIM            0
  14.  
  15. #define BORDER        0
  16. #define TITLE        1
  17. #define ACCENT        2
  18. #define NORMAL        3
  19. #define ALL            4
  20.  
  21. #define TRUE        1
  22. #define FALSE        0
  23. #define ERROR      -1
  24. #define OK            0
  25.  
  26. extern unsigned int maxy;
  27.  
  28. /* Window controller structures */
  29.  
  30. typedef struct field {  /* data entry field description */
  31.   char *fmask;          /* field data entry mask     */
  32.   int fprot;            /* field protection         */
  33.   char *fbuff;            /* field buffer            */
  34.   int ftype;            /* field type             */
  35.   int frow;                /* field row            */
  36.   int fcol;                /* field column            */
  37.   void (*fhelp)();        /* field help function         */
  38.   char *fhwin;            /* field help window        */
  39.   int flx,fly;            /* help window location        */
  40.   int (*fvalid)();        /* field validation function    */
  41.   struct field *fnxt;    /* next field on template    */
  42.   struct field *fprv;    /* previous field on template    */
  43. } FIELD;
  44.  
  45. typedef struct _wnd {
  46.   int _wv;            /* true if window is visible     */
  47.   int _hd;            /* true if window is hidden    */
  48.   char *_ws;        /* points to window save block  */
  49.   char *_tl;        /* points to window title    */
  50.   int _wx;            /* nw x coordinate        */
  51.   int _wy;            /* nw y coordinate        */
  52.   int _ww;            /* window width            */
  53.   int _wh;            /* window height        */
  54.   int _wsp;            /* scroll pointer        */
  55.   int _sp;            /* selection pointer        */
  56.   int _cr;            /* cursor x location        */
  57.   int btype;        /* border type            */
  58.   int wcolor[4];    /* colors for window        */
  59.   int _pn;            /* previous normal color    */
  60.   struct _wnd *_nx;    /* points to next window    */
  61.   struct _wnd *_pv;    /* points to prev window    */
  62.   FIELD *_fh;        /* points to 1st data entry fld    */
  63.   FIELD *_ft;        /* points to last data entry fld*/
  64. } WINDOW;
  65.  
  66. typedef struct w_menu {
  67.   char *mname;
  68.   char **mselcs;
  69.   void (**func)();
  70. } MENU;
  71.  
  72.  
  73. typedef struct k_menu {
  74.     char *mname;
  75.     char **mselcs;
  76.     int  *returnkey;
  77. } KMENU;
  78.  
  79. #define SAV            (wnd->_ws)
  80. #define WTITLE        (wnd->_tl)
  81. #define COL            (wnd->_wx)
  82. #define ROW            (wnd->_wy)
  83. #define WIDTH        (wnd->_ww)
  84. #define HEIGHT        (wnd->_wh)
  85. #define SCROLL        (wnd->_wsp)
  86. #define SELECT        (wnd->_sp)
  87. #define WCURS        (wnd->_cr)
  88. #define WBORDER        (wnd->wcolor[BORDER])
  89. #define WTITLEC        (wnd->wcolor[TITLE])
  90. #define WACCENT        (wnd->wcolor[ACCENT])
  91. #define WNORMAL        (wnd->wcolor[NORMAL])
  92. #define PNORMAL        (wnd->_pn)
  93. #define BTYPE        (wnd->btype)
  94. #define NEXT        (wnd->_nx)
  95. #define PREV        (wnd->_pv)
  96. #define WCOLOR        (wnd->wcolor)
  97. #define VISIBLE        (wnd->_wv)
  98. #define HIDDEN        (wnd->_hd)
  99. #define FHEAD        (wnd->_fh)
  100. #define FTAIL        (wnd->_ft)
  101.  
  102. #define NW        (wcs[wnd->btype].nw)
  103. #define NE        (wcs[wnd->btype].ne)
  104. #define SE        (wcs[wnd->btype].se)
  105. #define SW        (wcs[wnd->btype].sw)
  106. #define SIDE        (wcs[wnd->btype].side)
  107. #define LINE        (wcs[wnd->btype].line)
  108.  
  109. /* function prototypes and macros */
  110.  
  111. /* general-purpose functions and macros */
  112.  
  113. void pascal clear_screen (void);
  114. int pascal vmode(void);
  115. void pascal cursor(int,int);
  116. void pascal curr_cursor(int *,int *);
  117. int pascal cursor_type(void);
  118. void pascal set_cursor_type(int);
  119. int pascal get_char(void);
  120. int pascal scroll_lock(void);
  121. void pascal vpoke (unsigned,unsigned,unsigned);
  122. int pascal vpeek(unsigned,unsigned);
  123. /*
  124. #define vpoke(vseg,adr,chr) poke(vseg,adr,chr)
  125. #define vpeek(vseg,adr) peek(vseg,adr)
  126. */
  127.  
  128. /* window functions and macros*/
  129.  
  130. WINDOW * pascal establish_window (int,int,int,int);
  131. void pascal set_border(WINDOW *,int);
  132. void pascal set_colors(WINDOW *,int,int,int,int);
  133. void pascal set_intensity (WINDOW *,int);
  134. void pascal set_title(WINDOW *,char *);
  135. void pascal display_window(WINDOW *);
  136. void pascal delete_window(WINDOW *);
  137. void pascal clear_window (WINDOW *);
  138. void pascal hide_window(WINDOW *);
  139. void cdecl  wprintf(WINDOW *,char *,...);
  140. void pascal wputchar (WINDOW *,int);
  141. void cdecl  wprintfraw(WINDOW *,char *,...);
  142. void pascal wputcharaw (WINDOW *,int);
  143. void pascal close_all(void);
  144. void pascal wcursor(WINDOW *,int x,int y);
  145. void pascal wframe(WINDOW *wnd);
  146. void pascal error_message(char *);
  147. void pascal any_message(char *);
  148. void pascal _anymsg(char *,char *);
  149. void pascal clear_message(void);
  150. int  pascal get_selection(WINDOW *,int,char *);
  151. int  pascal hkmenu (char **selcs, char *keys, int *start);
  152.  
  153. #define reverse_video(wnd)wnd->wcolor[3]=wnd->wcolor[2]
  154. #define normal_video(wnd)wnd->wcolor[3]=wnd->_pn
  155. #define rmove_window(wnd,x,y) repos_wwnd(wnd,x,y,0)
  156. #define move_window(wnd,x,y) repos_wnd,COL-x,ROW-y,0)
  157. #define forefront(wnd) repos_wnd(wnd,0,0,1)
  158. #define rear_window(wnd) repos_wnd(wnd,0,0,-1)
  159.  
  160. /* internal to window processes */
  161.  
  162. void pascal accent(WINDOW *);
  163. void pascal deaccent(WINDOW *);
  164. void pascal scroll(WINDOW *,int);
  165. void pascal repos_wnd(WINDOW *,int,int,int);
  166. void pascal acline(WINDOW *,int);
  167. #define accent(wnd)acline(wnd,WACCENT)
  168. #define deaccent(wnd)acline(wnd,WNORMAL)
  169. #define clr(bg,fg,in)((fg)|(bg<<4)|(in))
  170. #define vad(x,y) ((y) * (maxx * 2) + (x) * 2)
  171. #ifdef FASTWINDOWS
  172. #define cht (c,a) (((c)&255) | ((a)<<8))
  173. #define displ(w,x,y,c,a) vpoke(VSG,vad(x+COL,y+ROW),(((c)&255) | ((a)<<8)))
  174. #define dget(w,x,y) vpeek(VSG,vad(x+COL,y+ROW))
  175. #define verify_wnd(w) (*(w)=listtail)!=0
  176. #else
  177. void pascal displ(WINDOW *wnd,int x,int y,int ch,int at);
  178. #endif
  179.  
  180. /* Text editor function */
  181.  
  182. char * pascal text_editor(WINDOW *,char *,unsigned);
  183.  
  184. /* Menu function */
  185.  
  186. void pascal menu_select(char *name,MENU *mn);
  187. int  pascal kmenu_select(char *name,KMENU *mn);
  188.  
  189. /* Help fundtions */
  190.  
  191. void pascal load_help(char *);
  192. void pascal set_help(char *,int,int);
  193.  
  194. /* Data entry functions */
  195.  
  196. void pascal init_template(WINDOW *);
  197. FIELD * pascal establish_field(WINDOW *,int,int,char *, char *,int);
  198. void pascal clear_template(WINDOW *);
  199. void pascal prep_template(WINDOW *);
  200. void pascal field_tally(WINDOW *);
  201. int  pascal data_entry(WINDOW *);
  202. void pascal wprompt(WINDOW *,int,int,char *);
  203. void pascal error_message(char *);
  204. void pascal clear_notice(void);
  205. void pascal field_window(FIELD *,char *,int,int);
  206. void pascal disp_field(WINDOW *wnd,char *bf,char *msk);
  207.  
  208. #define field_protect(f,s)     f->fprot=s
  209. #define field_help(f,h)        f->fhelp=h
  210. #define field_validate(f,v)    f->fvalid=v
  211.  
  212. void pascal save_screen(void);
  213. void pascal redraw_screen(void);
  214. void pascal show_mouse(void);
  215. void pascal hide_mouse(void);
  216. void pascal confine_mouse(WINDOW *wnd);
  217. void pascal pause_msg(void);
  218. void pascal nopause_msg(void);
  219. int pascal get_screen_char (int x,int y);
  220. void pascal move_mouse (int x,int y);
  221. int pascal generic_mouse_input (WINDOW *wnd);
  222. void pascal reconfine_mouse(void);
  223.  
  224. #define SHOWMOUSE show_mouse()
  225. #define HIDEMOUSE hide_mouse()
  226. #define CONFINEMOUSE(x) confine_mouse(x)
  227.